package announcement

import (
	"context"
	"github.com/google/wire"
	"go.manyji.com/lib/mysql"
	"sieve_admin_server/app/dao/util"
	"sieve_admin_server/app/schema"
)

var (
	AnnouncementSet = wire.NewSet(wire.Struct(new(AnnouncementRepo), "*"))
)

type AnnouncementRepo struct {
	DB *mysql.DB
}

func (a *AnnouncementRepo) Create(ctx context.Context, items map[string]interface{}) error {

	_, err := util.Create(ctx, Announcement{}.TableName(), a.DB, items)
	return err
}

func (a *AnnouncementRepo) SoftDelete(ctx context.Context, id uint64) error {

	return util.SoftDelete(ctx, Announcement{}.TableName(), a.DB, id)
}

func (a *AnnouncementRepo) Update(ctx context.Context, reqArgs map[string]interface{}, repKeys map[string]interface{}) error {

	return util.Update(ctx, Announcement{}.TableName(), a.DB, reqArgs, repKeys)
}

func (a *AnnouncementRepo) Query(ctx context.Context, reqArgs map[string]interface{}, p schema.PaginationParam, repKeys []string) (interface{}, error) {

	return util.Query(ctx, Announcement{}, a.DB, reqArgs, p, repKeys)
}
